package com.web.portal.controller.portal;

import com.web.portal.controller.admin.CategoryAdminApi;
import com.web.portal.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "分类查看")
@Slf4j
@RestController
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryAdminApi categoryAdminApi;
    /**
     * 获取分类
     * <p>
     * 使用的case:修改的时候，获取一下。填充弹窗
     * 不获取也是可以的，从列表里获取数据
     * <p>
     * 权限：管理员权限
     *
     * @param categoryId
     * @return
     */
    @ApiOperation(value = "用id获取分类")
    @GetMapping("find_categories/{categoryId}")
    public ResponseResult getCategory(@PathVariable("categoryId") String categoryId) {
       return categoryAdminApi.getCategory(categoryId);
    }

    //3 条件查询带分页
    @ApiOperation(value = "分类查询带分页")
    @PostMapping("find_categories/{current}/{limit}")
    public ResponseResult findCategories(@PathVariable long current,
                                         @PathVariable long limit) {
        return categoryAdminApi.findCategories(current,limit);
    }
}
